<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class City extends Model
{
    use HasDateTimeFormatter;
    use SoftDeletes;

    //城市表
    protected $table = 'city';

    /*
     * 获取所有区域
     */
    public static function getAllArea()
    {
        return self::where('name','like',"__区")->limit(10)->get();
    }
    /*
    * 处理数据把关联数组换为索引数组
    */
    public static function handleData($data)
    {
        $lastData = [];
        foreach ($data as $k=>$v){
            $lastData[$v['id']] = $v['name'];
        }
        return $lastData;
    }


}
